<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Zend_Service_Akismet - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.service.akismet.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.service.akismet.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.service.introduction.html">Introdu&ccedil;&atilde;o</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.service.html">Zend_Service</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.service.amazon.html">Zend_Service_Amazon</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.service.akismet" class="section"><div class="info"><h1 class="title">Zend_Service_Akismet</h1></div>
    

    <div class="section" id="zend.service.akismet.introduction"><div class="info"><h1 class="title">Introduction</h1></div>
        

        <p class="para">
            <span class="classname">Zend_Service_Akismet</span> provides a client for the <a href="http://akismet.com/development/api/" class="link external">&raquo; Akismet <acronym class="acronym">API</acronym></a>.
            The Akismet service is used to determine if incoming data is
            potentially spam. It also exposes methods for submitting data as
            known spam or as false positives (ham). It was originally intended to help
            categorize and identify spam for Wordpress, but it can be used for any
            type of data.
        </p>

        <p class="para">
            Akismet requires an <acronym class="acronym">API</acronym> key for usage. You can get one by signing
            up for a <a href="http://wordpress.com/" class="link external">&raquo; WordPress.com</a>
            account. You do not need to activate a blog. Simply acquiring the
            account will provide you with the <acronym class="acronym">API</acronym> key.
        </p>

        <p class="para">
            Akismet requires that all requests contain a <acronym class="acronym">URL</acronym> to
            the resource for which data is being filtered. Because of
            Akismet&#039;s origins in WordPress, this resource is called the blog
            <acronym class="acronym">URL</acronym>. This value should be passed as the second argument to the
            constructor, but may be reset at any time using the
             <span class="methodname">setBlogUrl()</span> method, or overridden by specifying a
            &#039;blog&#039; key in the various method calls.
        </p>
    </div>

    <div class="section" id="zend.service.akismet.verifykey"><div class="info"><h1 class="title">Verify an API key</h1></div>
        

        <p class="para">
             <span class="methodname">Zend_Service_Akismet::verifyKey($key)</span> is used to
            verify that an Akismet <acronym class="acronym">API</acronym> key is valid. In most cases, you
            will not need to check, but if you need a sanity check, or
            to determine if a newly acquired key is active, you may do
            so with this method.
        </p>

        <pre class="programlisting brush: php">
// Instantiate with the API key and a URL to the application or
// resource being used
$akismet = new Zend_Service_Akismet($apiKey,
                                    &#039;http://framework.zend.com/wiki/&#039;);
if ($akismet-&gt;verifyKey($apiKey) {
    echo &quot;Key is valid.\n&quot;;
} else {
    echo &quot;Key is not valid\n&quot;;
}
</pre>


        <p class="para">
            If called with no arguments,  <span class="methodname">verifyKey()</span> uses
            the <acronym class="acronym">API</acronym> key provided to the constructor.
        </p>

        <p class="para">
             <span class="methodname">verifyKey()</span> implements Akismet&#039;s
            <code class="code">verify-key</code> REST method.
        </p>
    </div>

    <div class="section" id="zend.service.akismet.isspam"><div class="info"><h1 class="title">Check for spam</h1></div>
        

        <p class="para">
             <span class="methodname">Zend_Service_Akismet::isSpam($data)</span> is used to
            determine if the data provided is considered spam by
            Akismet. It accepts an associative array as the sole
            argument. That array requires the following keys be set:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <code class="code">user_ip</code>, the IP address of the user
                    submitting the data (not your IP address, but that
                    of a user on your site).
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">user_agent</code>, the reported UserAgent
                    string (browser and version) of the user submitting
                    the data.
                </p>
            </li>
        </ul>

        <p class="para">
            The following keys are also recognized specifically by the
            <acronym class="acronym">API</acronym>:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <code class="code">blog</code>, the fully qualified <acronym class="acronym">URL</acronym> to the
                    resource or application. If not specified, the <acronym class="acronym">URL</acronym>
                    provided to the constructor will be used.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">referrer</code>, the content of the
                    HTTP_REFERER header at the time of submission. (Note
                    spelling; it does not follow the header name.)
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">permalink</code>, the permalink location, if
                    any, of the entry the data was submitted to.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">comment_type</code>, the type of data
                    provided. Values specified in the <acronym class="acronym">API</acronym>
                    include &#039;comment&#039;, &#039;trackback&#039;, &#039;pingback&#039;, and an
                    empty string (&#039;&#039;), but it may be any value.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">comment_author</code>, the name of the person
                    submitting the data.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">comment_author_email</code>, the email of the
                    person submitting the data.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">comment_author_url</code>, the <acronym class="acronym">URL</acronym> or home page of the
                    person submitting the data.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">comment_content</code>, the actual data content
                    submitted.
                </p>
            </li>
        </ul>

        <p class="para">
            You may also submit any other environmental variables you
            feel might be a factor in determining if data is spam.
            Akismet suggests the contents of the entire $_SERVER array.
        </p>

        <p class="para">
            The  <span class="methodname">isSpam()</span> method will return either
            <b><tt>TRUE</tt></b> or <b><tt>FALSE</tt></b>, or throw an exception if the
            <acronym class="acronym">API</acronym> key is invalid.
        </p>

        <div class="example" id="zend.service.akismet.isspam.example-1"><div class="info"><p><b>Example #1 isSpam() Usage</b></p></div>
            

            <pre class="programlisting brush: php">
$data = array(
    &#039;user_ip&#039;              =&gt; &#039;111.222.111.222&#039;,
    &#039;user_agent&#039;           =&gt; &#039;Mozilla/5.0 &#039; . (Windows; U; Windows NT &#039; .
                              &#039;5.2; en-GB; rv:1.8.1) Gecko/20061010 &#039; .
                              &#039;Firefox/2.0&#039;,
    &#039;comment_type&#039;         =&gt; &#039;contact&#039;,
    &#039;comment_author&#039;       =&gt; &#039;John Doe&#039;,
    &#039;comment_author_email&#039; =&gt; &#039;nospam@myhaus.net&#039;,
    &#039;comment_content&#039;      =&gt; &quot;I&#039;m not a spammer, honest!&quot;
);
if ($akismet-&gt;isSpam($data)) {
    echo &quot;Sorry, but we think you&#039;re a spammer.&quot;;
} else {
    echo &quot;Welcome to our site!&quot;;
}
</pre>

        </div>

        <p class="para">
             <span class="methodname">isSpam()</span> implements the <code class="code">comment-check</code>
            Akismet <acronym class="acronym">API</acronym> method.
        </p>
    </div>

    <div class="section" id="zend.service.akismet.submitspam"><div class="info"><h1 class="title">Submitting known spam</h1></div>
        

        <p class="para">
            Spam data will occasionally get through the filter. If you discover spam that you feel
            should have been caught, you can submit it to Akismet to help improve their filter.
        </p>

        <p class="para">
             <span class="methodname">Zend_Service_Akismet::submitSpam()</span> takes the same data
            array as passed to  <span class="methodname">isSpam()</span>, but does not return a
            value. An exception will be raised if the <acronym class="acronym">API</acronym> key used is invalid.
        </p>

        <div class="example" id="zend.service.akismet.submitspam.example-1"><div class="info"><p><b>Example #2 submitSpam() Usage</b></p></div>
            

            <pre class="programlisting brush: php">
$data = array(
    &#039;user_ip&#039;              =&gt; &#039;111.222.111.222&#039;,
    &#039;user_agent&#039;           =&gt; &#039;Mozilla/5.0 (Windows; U; Windows NT 5.2;&#039; .
                              &#039;en-GB; rv:1.8.1) Gecko/20061010 Firefox/2.0&#039;,
    &#039;comment_type&#039;         =&gt; &#039;contact&#039;,
    &#039;comment_author&#039;       =&gt; &#039;John Doe&#039;,
    &#039;comment_author_email&#039; =&gt; &#039;nospam@myhaus.net&#039;,
    &#039;comment_content&#039;      =&gt; &quot;I&#039;m not a spammer, honest!&quot;
);
$akismet-&gt;submitSpam($data));
</pre>

        </div>

        <p class="para">
             <span class="methodname">submitSpam()</span> implements the <code class="code">submit-spam</code>
            Akismet <acronym class="acronym">API</acronym> method.
        </p>
    </div>

    <div class="section" id="zend.service.akismet.submitham"><div class="info"><h1 class="title">Submitting false positives (ham)</h1></div>
        

        <p class="para">
            Data will occasionally be trapped erroneously as spam by Akismet. For this reason,
            you should probably keep a log of all data trapped as spam by Akismet and review it
            periodically. If you find such occurrences, you can submit the data to Akismet as
            &quot;ham&quot;, or a false positive (ham is good, spam is not).
        </p>

        <p class="para">
             <span class="methodname">Zend_Service_Akismet::submitHam()</span> takes the same data
            array as passed to  <span class="methodname">isSpam()</span> or
             <span class="methodname">submitSpam()</span>, and, like  <span class="methodname">submitSpam()</span>,
            does not return a value. An exception will be raised if the <acronym class="acronym">API</acronym> key
            used is invalid.
        </p>

        <div class="example" id="zend.service.akismet.submitham.example-1"><div class="info"><p><b>Example #3 submitHam() Usage</b></p></div>
            

            <pre class="programlisting brush: php">
$data = array(
    &#039;user_ip&#039;              =&gt; &#039;111.222.111.222&#039;,
    &#039;user_agent&#039;           =&gt; &#039;Mozilla/5.0 (Windows; U; Windows NT 5.2;&#039; .
                              &#039;en-GB; rv:1.8.1) Gecko/20061010 Firefox/2.0&#039;,
    &#039;comment_type&#039;         =&gt; &#039;contact&#039;,
    &#039;comment_author&#039;       =&gt; &#039;John Doe&#039;,
    &#039;comment_author_email&#039; =&gt; &#039;nospam@myhaus.net&#039;,
    &#039;comment_content&#039;      =&gt; &quot;I&#039;m not a spammer, honest!&quot;
);
$akismet-&gt;submitHam($data));
</pre>

        </div>

        <p class="para">
             <span class="methodname">submitHam()</span> implements the <code class="code">submit-ham</code>
            Akismet <acronym class="acronym">API</acronym> method.
        </p>
    </div>

    <div class="section" id="zend.service.akismet.accessors"><div class="info"><h1 class="title">Zend-specific Methods</h1></div>
        

        <p class="para">
            While the Akismet <acronym class="acronym">API</acronym> only specifies four methods,
            <span class="classname">Zend_Service_Akismet</span> has several additional methods
            that may be used for retrieving and modifying internal properties.
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                     <span class="methodname">getBlogUrl()</span> and  <span class="methodname">setBlogUrl()</span>
                    allow you to retrieve and modify the blog <acronym class="acronym">URL</acronym> used in
                    requests.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">getApiKey()</span> and  <span class="methodname">setApiKey()</span>
                    allow you to retrieve and modify the <acronym class="acronym">API</acronym> key used in
                    requests.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">getCharset()</span> and  <span class="methodname">setCharset()</span>
                    allow you to retrieve and modify the character set used to make the request.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">getPort()</span> and  <span class="methodname">setPort()</span>
                    allow you to retrieve and modify the <acronym class="acronym">TCP</acronym> port used to make
                    the request.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">getUserAgent()</span> and
                     <span class="methodname">setUserAgent()</span> allow you to retrieve and modify the
                    <acronym class="acronym">HTTP</acronym> user agent used to make the request. Note: this is not
                    the user_agent used in data submitted to the service, but rather the value
                    provided in the <acronym class="acronym">HTTP</acronym> User-Agent header when making a request
                    to the service.
                </p>

                <p class="para">
                    The value used to set the user agent should be of the form
                    <code class="code">some user agent/version | Akismet/version</code>. The default is
                    <code class="code">Zend Framework/ZF-VERSION | Akismet/1.11</code>, where
                    <code class="code">ZF-VERSION</code> is the current Zend Framework version as stored in the
                    <b><tt>Zend_Framework::VERSION</tt></b> constant.
                </p>
            </li>
        </ul>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.service.introduction.html">Introdu&ccedil;&atilde;o</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.service.html">Zend_Service</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.service.amazon.html">Zend_Service_Amazon</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="reference.html">Refer&ecirc;ncia do Zend Framework</a></li>
  <li class="header up"><a href="zend.service.html">Zend_Service</a></li>
  <li><a href="zend.service.introduction.html">Introdu&ccedil;&atilde;o</a></li>
  <li class="active"><a href="zend.service.akismet.html">Zend_Service_Akismet</a></li>
  <li><a href="zend.service.amazon.html">Zend_Service_Amazon</a></li>
  <li><a href="zend.service.amazon.ec2.html">Zend_Service_Amazon_Ec2</a></li>
  <li><a href="zend.service.amazon.ec2.instance.html">Zend_Service_Amazon_Ec2: Instances</a></li>
  <li><a href="zend.service.amazon.ec2.windows.instance.html">Zend_Service_Amazon_Ec2: Windows Instances</a></li>
  <li><a href="zend.service.amazon.ec2.reserved.instance.html">Zend_Service_Amazon_Ec2: Reserved Instances</a></li>
  <li><a href="zend.service.amazon.ec2.cloudwatch.html">Zend_Service_Amazon_Ec2: CloudWatch Monitoring</a></li>
  <li><a href="zend.service.amazon.ec2.images.html">Zend_Service_Amazon_Ec2: Amazon Machine Images (AMI)</a></li>
  <li><a href="zend.service.amazon.ec2.ebs.html">Zend_Service_Amazon_Ec2: Elastic Block Storage (EBS)</a></li>
  <li><a href="zend.service.amazon.ec2.elasticip.html">Zend_Service_Amazon_Ec2: Elastic IP Addresses</a></li>
  <li><a href="zend.service.amazon.ec2.keypairs.html">Zend_Service_Amazon_Ec2: Keypairs</a></li>
  <li><a href="zend.service.amazon.ec2.zones.html">Zend_Service_Amazon_Ec2: Regions and Availability Zones</a></li>
  <li><a href="zend.service.amazon.ec2.securitygroups.html">Zend_Service_Amazon_Ec2: Security Groups</a></li>
  <li><a href="zend.service.amazon.s3.html">Zend_Service_Amazon_S3</a></li>
  <li><a href="zend.service.amazon.sqs.html">Zend_Service_Amazon_Sqs</a></li>
  <li><a href="zend.service.audioscrobbler.html">Zend_Service_Audioscrobbler</a></li>
  <li><a href="zend.service.delicious.html">Zend_Service_Delicious</a></li>
  <li><a href="zend.service.developergarden.html">Zend_Service_DeveloperGarden</a></li>
  <li><a href="zend.service.ebay.html">Zend_Service_Ebay</a></li>
  <li><a href="zend.service.ebay.finding.html">Zend_Service_Ebay_Finding</a></li>
  <li><a href="zend.service.flickr.html">Zend_Service_Flickr</a></li>
  <li><a href="zend.service.livedocx.html">Zend_Service_LiveDocx</a></li>
  <li><a href="zend.service.nirvanix.html">Zend_Service_Nirvanix</a></li>
  <li><a href="zend.service.recaptcha.html">Zend_Service_ReCaptcha</a></li>
  <li><a href="zend.service.short-url.html">Zend_Service_ShortUrl</a></li>
  <li><a href="zend.service.simpy.html">Zend_Service_Simpy</a></li>
  <li><a href="zend.service.slideshare.html">Zend_Service_SlideShare</a></li>
  <li><a href="zend.service.strikeiron.html">Zend_Service_StrikeIron</a></li>
  <li><a href="zend.service.strikeiron.bundled-services.html">Zend_Service_StrikeIron: Bundled Services</a></li>
  <li><a href="zend.service.strikeiron.advanced-uses.html">Zend_Service_StrikeIron: Advanced Uses</a></li>
  <li><a href="zend.service.technorati.html">Zend_Service_Technorati</a></li>
  <li><a href="zend.service.twitter.html">Zend_Service_Twitter</a></li>
  <li><a href="zend.service.windowsazure.html">Zend_Service_WindowsAzure</a></li>
  <li><a href="zend.service.windowsazure.storage.blob.html">Zend_Service_WindowsAzure_Storage_Blob</a></li>
  <li><a href="zend.service.windowsazure.diagnostics.manager.html">Zend_Service_WindowsAzure_Diagnostics_Manager</a></li>
  <li><a href="zend.service.windowsazure.storage.queue.html">Zend_Service_WindowsAzure_Storage_Queue</a></li>
  <li><a href="zend.service.windowsazure.storage.table.html">Zend_Service_WindowsAzure_Storage_Table</a></li>
  <li><a href="zend.service.yahoo.html">Zend_Service_Yahoo</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>